import { createRouter, createWebHistory } from 'vue-router'
import  subCategory  from '../views/subCategory/index.vue'
import detail from '../views/detail/index.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path:'/',
      component: ()=> import('../views/Layout/index.vue'),
      children:[
        {
          path:'',
          component: () =>import('../views/Home/index.vue')
        },
        {
          path:'/category/:id',
          component: () =>import('../views/Category/index.vue')
        },
        {
          path:'/category/sub/:id',
          name:'subCategory',
          component:subCategory
        },
        {
          path:'/detail/:id',
          name:'detail',
          component:detail
        }
      ]
    },
    {
      path:'/login',
      component:() => import('../views/Login/index.vue')
    },
  ],
  scrollBehavior() {
    return {
      top:0
    }
  }
})

export default router
